package com.zxd.generics_method;

import java.util.ArrayList;

/**
 * ClassName:Animal
 * Package:com.zxd.generics_method
 *
 * @Date:2023/9/22 13:58
 * @Author:zxde
 */
public class Animal {
    public static void main(String[] args) {
        ArrayList<Car> arrayListCar = new ArrayList<>();
        arrayListCar.add(new Car());
        arrayListCar.add(new Car());

        ArrayList<Cat> arrayListCat = new ArrayList<>();
        arrayListCat.add(new Cat());
        arrayListCat.add(new Cat());

        ArrayList<Dog> arrayListDog = new ArrayList<>();
        arrayListDog.add(new Dog());
        arrayListDog.add(new Dog());

        go(arrayListCat);
        go(arrayListDog);
        //报错 go(arrayListCar);


        go2(arrayListCat);
        go2(arrayListDog);
//        go2(arrayListCar);
    }

    public static <T extends Animal> void go(ArrayList<T> list) {
        System.out.println("process logic");
    }

    public static void go2(ArrayList<? extends Animal> list) {
        System.out.println("process logic");
    }
}
